<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>${ empty title ? '添加图书': title }</title>
    <base href="${ pageContext.servletContext.contextPath }/">
    <link rel="icon" href="statics/img/favicon.svg" sizes="any" type="image/svg+xml">
    <link rel="stylesheet" href="statics/css/base.css">
    <link rel="stylesheet" href="statics/css/form.css">
</head>
<body>
    <%@include file="/pages/common/header.jsp" %>
    <!-- 主体 -->
    <main class="flex-center">
        <form action="manager/book/${ empty title ? 'add' : 'update' }" method="POST" enctype="multipart/form-data">
            <p class="tips ${ empty message ? 'hide' : '' }"> 
                <img src="statics/img/灯泡.png">
                <span>${ message }</span>
            </p>
            <p class="file">
            	图书封面：
            	<label for="image">
            		<span>选择图片</span> 
            		<img class="${ empty book.imgPath ? 'hide' : '' }" src="${ book.imgPath.indexOf('/upload') == 0 ? pageContext.request.contextPath : '' }${ book.imgPath }">
            	</label>
            	<input type="file" id="image" name="image">
            </p>
            <input type="hidden" name="id" value="${ book.id }">
            <input type="hidden" name="default_image" value="${ book.imgPath }">
            <input type="hidden" name="referer" value="${ header.Referer }">
            <p>图书名称：<input type="text" name="name" value="${ book.name }" placeholder="请输入图书名"></p>
            <p>图书作者：<input type="text" name="author" value="${ book.author }" placeholder="请输入作者名"></p>
            <p>图书单价：<input type="number" name="price" value="${ book.price }" placeholder="请输入图书单价" min="0" step="0.01"></p>
            <p>图书销量：<input type="number" name="sales" value="${ book.sales }" placeholder="请输入图书销量" min="0"></p>
            <p>图书库存：<input type="number" name="stock" value="${ book.stock }" placeholder="请输入图书库存" min="0"></p>
            <p><button class="btn btn-success w-100">${ empty title ? '添加图书': title }</button></p>
        </form>
    </main>
    <%@include file="/pages/common/footer.jsp" %>
    
    <script src="statics/js/form.js"></script>
    <script src="statics/js/message_box.js"></script>
    <script src="statics/js/book.js"></script>
</body>
</html>